import logging


class MyLogger(object):
    def __init__(self, logger_name, log_level: str):
        # 创建logger
        self.logger = logging.getLogger(logger_name)
        self.logger.setLevel(log_level)

        # # 创建handler, 写入日志文件
        # fh = logging.FileHandler(log_path_, encoding='utf-8')
        # fh.setLevel(logging.INFO)

        # # 创建handler, 输出到控制台
        ch = logging.StreamHandler()

        # 定义handler的输出格式
        formatter = logging.Formatter('%(asctime)s-%(name)s-%(levelname)s-%(message)s')
        # fh.setFormatter(formatter)
        ch.setFormatter(formatter)

        # 添加handler
        # self.logger.addHandler(fh)
        self.logger.addHandler(ch)

    def get_log(self):
        return self.logger
